package com.weimengchao;

import com.weimengchao.domain.NacosConfig;
import com.weimengchao.entity.OrderInfo;
import com.weimengchao.mapper.OrderInfoMapper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import javax.sql.DataSource;

@SpringBootApplication
public class NacosConfigExampleApplication {

    public static void main(String[] args) throws InterruptedException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(NacosConfigExampleApplication.class, args);
//        while (true) {
//            try {
//                DataSource dataSource = applicationContext.getBean(DataSource.class);
//                System.out.println(dataSource);
//                NacosConfig nacosConfig = applicationContext.getBean(NacosConfig.class);
//                nacosConfig.toString();
//                OrderInfoMapper orderInfoMapper = applicationContext.getBean(OrderInfoMapper.class);
//                OrderInfo orderInfo = orderInfoMapper.selectById(1548436386493759499L);
//                System.out.println();
//                System.out.println(nacosConfig + " - " + nacosConfig.address());
//                System.out.println("orderInfo: " + orderInfo);
//                System.out.println();
//            } catch (Exception e) {
//                e.printStackTrace();
//            } finally {
//                Thread.sleep(5000);
//            }
//        }
    }

}
